<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Usuarios Oracle</title>
    </h:head>
    <h:body>
        <h:form  >
            <p:growl id="msgUsers" showDetail="true" 
                     life="300" autoUpdate="true"/>
            <h:panelGrid style="margin: 0 auto">
                <p:outputLabel value="ADMINISTRACI&Oacute;N DE USUARIOS" style="color: #2480BC; font-weight: bold; font-size: 1.3em;"/>
            </h:panelGrid>
            <h:form id="UsersList" >
                <p:tabView dynamic="true" activeIndex="#{userBean.ntab}" id="tabViewUser">
                    
                    <p:tab title="Usuarios" disabled="false" > 
                        
                        <center><p:outputLabel value="Selecci&oacute;n de Usuarios" style="color: #2480BC; font-size: 1.1em"/></center>
                
                        <center><p:commandButton value="Editar" 
                                action="#{userBean.edit}" 
                                update="tabViewUser"/>
                        <label>&emsp;&emsp;</label>
                        <p:commandButton icon="ui-icon-trash" value="Eliminar"
                                         ajax="false" action="#{userBean.delete()}"
                                         update="DTuser">
                        </p:commandButton></center>
                        
                        <p:dataTable id="DTuser" var="user" 
                                     value="#{userBean.users}" 
                                    paginator="true" rows="5" 
                                    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                                    rowsPerPageTemplate="5,10,15"
                                    selection="#{userBean.selectedUser}"
                                    selectionMode="single"
                                    rowKey="#{user.name}"
                                    >
                        <f:facet name="header" > 
                            Tablas del Usuario
                       </f:facet>

                            <p:column headerText="Nombre de Usuario">  
                                <h:outputText value="#{user.username}" />  
                            </p:column>  

                            <p:column headerText="Estado de la Cuenta">  
                                <h:outputText value="#{user.accountStatus}" />  
                            </p:column>  

                            <p:column headerText="Table Space por defecto">  
                                <h:outputText value="#{user.defaultTablespace}" />  
                            </p:column>  

                            <p:column headerText="Table Space por temporal">  
                                <h:outputText value="#{user.temporaryTablespace}" />  
                            </p:column>  
                        </p:dataTable>

                    </p:tab>
                    
                    <p:tab title="Crear" disabled="false" > 
                        <ui:include src="createUser.xhtml" />
                    </p:tab>
                    
                    <p:tab title="Modificar" disabled="false" > 
                        
                        <h:form>
                            <p:growl id="msgUsers2" showDetail="true" 
                                    life="300" autoUpdate="true"/>
                            <p:fieldset legend="Cuenta de Usuario" 
                                        toggleable="true" toggleSpeed="500" >
                                <p:ajax event="toggle"  update="msgUsers2" />

                                <h:panelGrid columns="2" cellspacing="3">

                                    <h:outputText value="Nombre de Usuario: " />
                                    <p:inputText value="#{userBean.selectedUser.name}" disabled="true"/>

                                    <h:outputText value="Autenticaci&oacute;n: " />
                                    <p:selectOneMenu id="prof" value="#{userBean.cub.tauthentication}" >  
                                        <f:selectItem itemLabel="Tipo de Autenticacion" itemValue="" />  
                                        <f:selectItems value="#{userBean.cub.autenticacion}" /> 
                                        <p:ajax    listener="#{userBean.cub.handleChange}" 
                                                    update="msgUsers2"/>
                                    </p:selectOneMenu>

                                    <h:outputText value="Contraseña: " />
                                    <p:password id ="password" value="#{userBean.cub.authentication}" />


                                    <h:outputText value="Confirmar Contraseña: " />
                                    <p:password id ="password2" value="#{userBean.cub.authentication2}" />


                                    <h:outputText value="Perfil " />

                                    <p:selectOneMenu id="profi" value="#{createUser.profile}" >  
                                        <f:selectItem itemLabel="Selecionar Perfil" itemValue="" />  
                                        <f:selectItems value="#{editProfileBean.profiles}" /> 
                                    </p:selectOneMenu>

                                    <h:outputText value="Contraseña caducada: " />
                                    <p:selectBooleanCheckbox value="#{userBean.cub.expires}" /> 

                                    <h:outputText value="Cuenta Bloqueada: " />
                                    <p:selectBooleanCheckbox value="#{userBean.cub.lock}" /> 
                                </h:panelGrid>

                            </p:fieldset>

                            <p:fieldset legend="TableSpace" collapsed="true"
                                        toggleable="true" toggleSpeed="500" >
                                <h:panelGrid columns="2" cellspacing="3">
                                    <h:outputText value="Tablespace por defecto: " />
                                    <p:selectOneMenu id="tablS" value="#{userBean.selectedUser.defaultTablespace}" >  
                                        <f:selectItem itemLabel="Selecionar TableSpace" itemValue="" />  
                                        <f:selectItems value="#{userBean.cub.tablespace}" /> 
                                    </p:selectOneMenu>

                                    <h:outputText value="Tablespace Temporal " />
                                    <p:selectOneMenu id="tablST" value="#{userBean.selectedUser.temporaryTablespace}" >  
                                        <f:selectItem itemLabel="Selecionar TableSpace" itemValue="" />  
                                        <f:selectItems value="#{userBean.cub.tablespace}" /> 
                                    </p:selectOneMenu>
                                </h:panelGrid>


                            </p:fieldset>

                            <p:fieldset legend="Privilegio" collapsed="true"
                                        toggleable="true" toggleSpeed="500" >
                                <label for="subtitle">Lista de Privilegios</label>  
                                <p:pickList id="pojoPickListUs" value="#{userBean.privileges}" 
                                            var="privilege" effect="bounce"
                                            itemValue="#{privilege}" itemLabel="#{privilege}" 
                                            showSourceControls="false" showTargetControls="false" 
                                            showSourceFilter="true" showTargetFilter="true" 
                                            showCheckbox="true" filterMatchMode="contains" >  

                                    <f:facet name="sourceCaption">Disponibles</f:facet>  
                                    <f:facet name="targetCaption">Agregados</f:facet>  

                                    <!--<p:ajax event="transfer" listener="{createUser.onTransfer}" update="growl" />-->  


                                    <p:column style="width:90%;">  
                                        #{privilege}  
                                    </p:column>  

                                </p:pickList> 
                            </p:fieldset>

                            <p:commandButton value="Modificar" 
                                 update="msgUsers2"
                                 action="#{userBean.edit()}"
                                 style="margin-top:5px" ajax="false"
                                 >
                            </p:commandButton> 
                        </h:form>
                        
                    </p:tab>
                    
                </p:tabView>
                
            </h:form>
        </h:form>
    </h:body>
</html>
